import 'package:flutter/material.dart';
import 'package:order/board/desk_page.dart';
import 'package:order/category_item.dart';
import 'package:order/constant/data.dart';
import 'package:order/generated/assets.dart';

import '../constant/app_colors.dart';

class Home extends StatefulWidget {
  const Home({super.key});

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int _currentSelected = 0;

  @override
  Widget build(BuildContext context) {
    double screenWidth = MediaQuery.of(context).size.width;
    return Scaffold(
      body: SizedBox(
        width: double.infinity,
        height: double.infinity,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Container(
              width: screenWidth * 0.2,
              height: double.infinity,
              decoration: const BoxDecoration(color: AppColors.bgWhite, boxShadow: [
                BoxShadow(
                  color: Color(0x00f5f5f5),
                  blurRadius: 1,
                  spreadRadius: 1,
                  offset: Offset(0, 8),
                )
              ]),
              child: Column(
                children: [
                  const SizedBox(height: 20,),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Image.asset(Assets.imagesIconLogo,height: 50,fit: BoxFit.fitHeight,),
                      Image.asset(Assets.imagesIconTitle,height: 60,fit: BoxFit.fitHeight,),
                    ],
                  ),
                  const SizedBox(height: 20,),
                  Column(
                    children: _buildCategory(),
                  )
                ],
              ),
            ),
            Expanded(
                child: IndexedStack(
                  children:[_buildBoard()],
                ))
          ],
        ),
      ),
    );
  }

  List<Widget> _buildCategory() {
    return List.generate(
        categories.length,
            (index) => CategoryItem(
          selected: index == _currentSelected,
          data: categories[index],
          onTap: () => {
            setState(() {
              _currentSelected = index;
            })
          },
        ));
  }

  Widget _buildBoard() {

    if(_currentSelected == 0){
      return Column(
        children: [
          Container(height: 50,)
        ],

      );
    }else{
      return const DeskPage();
    }
  }
}
